package com.blog.common.mapper.handler;

import cn.hutool.extra.spring.SpringUtil;
import com.blog.common.domain.util.FileUtils;
import com.blog.common.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;

import java.sql.Statement;
import java.util.Map;

import static com.blog.common.core.constant.CacheConstants.FILE_INFO;

/**
 * <p>
 * 统一查询结果处理类
 * </p>
 *
 * @author Valerie
 * @date 2023/5/20
 **/
@Intercepts({
        @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})
})
@Slf4j
public class MyResultInterceptor implements Interceptor {


    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        // 调用原始方法获取查询结果
        Object result = invocation.proceed();
        FileUtils.assignImageFields(result);
        // 返回处理后的结果
        return result;
    }
}

